package com.study.stater.config;

import com.study.stater.pojo.MySystemInfoProperties;
import com.study.stater.service.MyService;
import com.study.stater.service.impl.MyServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xl-9527
 * @since 2025/7/20
 **/
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(MySystemInfoProperties.class)
public class MyStarterAutoConfig {

    private final MySystemInfoProperties mySystemInfoProperties;

    private static final Logger log = LoggerFactory.getLogger(MyStarterAutoConfig.class);

    public MyStarterAutoConfig(final MySystemInfoProperties mySystemInfoProperties) {
        this.mySystemInfoProperties = mySystemInfoProperties;
    }

    @Bean
    @ConditionalOnMissingBean(MyService.class)
    MyService myService() {
        log.info("创建 {} Bean 通过自定义 Starter", MyService.class.getName());
        return new MyServiceImpl(mySystemInfoProperties);
    }
}
